const Mock = require('mockjs')

const PartspurchaseList=[];
for(let i=0;i<100;i++){
    PartspurchaseList.push(
        Mock.mock({
            id:'@increment',
            number:'@integer(111111,999999)',
            partname:'@first',
            partcode:'@integer(111111,999999)',
            partcategory:'@first',
            count:'@first',
            guider:'@first',
            state:'@integer(0,1)',
            remark:'',
            createtime:'@datetime'
        })
    )
}

const PartsRebateAccrualList=[];
for(let i=0;i<100;i++){
    PartsRebateAccrualList.push(
        Mock.mock({
            id:'@increment',
            number:'@integer(111111,999999)',
            entrystate:'@integer(0,1)',
            entrycost:'@integer(0,1)',
            supplier:'@first',
            paytype:'@integer(1,4)',
            guider:'@first',
            state:'@integer(0,1)',
            remark:'',
            createtime:'@datetime'
        })
    )
}
const PartsRebateReceiptList=[];
for(let i=0;i<100;i++){
    PartsRebateReceiptList.push(
        Mock.mock({
            id:'@increment',
            supplier:'@first',
            count:'@integer(1,4000)',
            totalmoney:'@integer(100000,4000000)',
            rebatemoney:'@integer(1000,400000)',
            guider:'@first',
            state:'@integer(0,1)',
            remark:'',
            createtime:'@datetime'
        })
    )
}

const PartsSaleList=[];
for(let i=0;i<100;i++){
    PartsSaleList.push(
        Mock.mock({
            id:'@increment',
            number:'@integer(1000000,9999999)',
            customername:'@first',
            partname:'@first',
            count:'@integer(1,4000)',
            totalmoney:'@integer(100000,4000000)',
            paytype:'@integer(1,3)',
            collectstate:'@integer(0,3)',
            guider:'@first',
            state:'@integer(0,1)',
            remark:'',
            createtime:'@datetime'
        })
    )
}


module.exports=[
    {
        url: '/api/finance/partspurchase',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PartspurchaseList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/finance/rebateaccrual',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PartsRebateAccrualList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/finance/rebatereceipt',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PartsRebateReceiptList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
        url: '/api/finance/partsale',
        type: 'get',
        response: config => {
          const { name, page = 1, limit = 20, sort } = config.query
    
          let mockList = PartsSaleList.filter(item => {
            return true
          })

    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },

    
]